<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ page contentType="text/html;charset=utf-8" language="java" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>admin search result</title>
<link rel="stylesheet" type="text/css" href="../resource/css/screen.css" />
<link rel="stylesheet" type="text/css" href="../resource/css/search.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/resource/js/jquery-1.4.2.js"></script>
</head>

<body>
    <div class="wrap">
         <div class="header">
              <div class="logo">
                 <a href="#"><img alt="logo" src="../resource/images/brand.gif" /></a>
              </div>
              <ul id="nav">
                 <li class="nav_image"><a title="Picture" href="${pageContext.request.contextPath}/sz/bgPicture.action?isAdmin=1"><img alt="picture" src="../resource/images/image.gif" /></a></li>
                      <li class="nav_video nav_current"><a title="Video" href="${pageContext.request.contextPath}/sz/bgVideo.action?isAdmin=1"><img alt="video" src="../resource/images/video.gif" /></a></li>
                      <li class="nav_audio"><a title="Audio" href="${pageContext.request.contextPath}/sz/bgAudio.action?isAdmin=1"><img alt="audio" src="../resource/images/audio.gif" /></a></li>
                      <li class="nav_model"><a title="Model" href="${pageContext.request.contextPath}/sz/bgModel.action?isAdmin=1"><img alt="model" src="../resource/images/model.gif" /></a></li>
                      <li class="nav_action"><a title="Activity" href="${pageContext.request.contextPath}/sz/bgActivity.action?isAdmin=1"><img alt="activity" src="../resource/images/action.gif" /></a></li>
              </ul>
             
              <div id="content">

               <form id="key_form" method="get" action="${pageContext.request.contextPath}/sz/bgPicture.action?isAdmin=1" >
               <input type="hidden" id="domain" value="${pageContext.request.contextPath}/sz/" />
               <div class="inputbox">
                 <div class="input_radio">
                  <p style="padding-top:11px;">
                  	<label for="radio_i1">关键字搜索</label>
                  </p>
                 </div>
               </div>
               <div id="key_search1" class="key_search">
                  <input class="key_t" name="picture.title" type="text" />
                  <input type="hidden" name="isAdmin" value="1" />
                  <input class="key_b" type="submit" value="" />
               </div>
               <div style="clear:both;"></div>
              </form>
              <p class="upload_link"><a id="pic_type" href="/shuzi/sz/bgPictureType.action">图片类型管理 </a>  <a id="pic_upload" href="/shuzi/sz/initialUploadPicture.action">图片上传</a></p>
          </div>
          </div>
         <div class="content">
             <div class="sidebar">
                 <img src="../resource/images/pic_top.gif" alt="图片分类列表" width="158" height="34"/>
                 <ul id="pictureType">
                     <c:forEach var="top" items="${types}">
                          <li title="${top.typeId}">
			                    <a class="side_list" href="#">${top.name}</a>
			                        <a class="side_del" title="${top.typeId}" href="#"><img alt="delete" src="../resource/images/cha.gif" /></a></li>
                     </c:forEach>
                 </ul>
             </div>
             
             <div class="main">
				<table id="list_table">
					<thead>
						<tr class="th_border">
							<th style="width:50px" class="check"><input type="checkbox" /></th>
							<th style="width:50px">缩略图</th>
							<th style="width:100px" class="file_name">文件名</th>
							<th style="width:170px">描述</th>
							<th style="width:85px">文件格式</th>
							<th style="width:86px">文件大小</th>
							<th style="width:170px">所属站点</th>
							<th style="width:70px"><a href="${pageContext.request.contextPath}/sz/delete${resultSet.type}List.action?" class="delete">删除所选</a></th>
					   </tr>
				   </thead>
				   <tbody>
                       <c:forEach var="top" items="${resultSet.list}" >
						            <tr>
									<td class="check"><input value="${top.id}" type="checkbox" /></td>
									<td>
                                        <c:choose>  
                                        <c:when test="${!empty top.minPictureUrl}">
                                        <img src="${top.minPictureUrl}" width="50" height="50" alt="" />
                                        </c:when>
                                        <c:otherwise>
                                            <img src="../resource/images/audio_show.jpg" width="50" height="50" alt="" />
                                        </c:otherwise>
                                        </c:choose>
                                    </td>
									<td class="file_name">${top.title}</td>
                                    <td class="description">${top.note}</td>
									<td>${top.fileType}</td>
									<td>${top.size }KB</td>
									<td>${top.server}</td>
									<td>
									    <a href="${pageContext.request.contextPath}/sz/getUnique${resultSet.type}.action?id=${top.id}"  class="change" target="_blank">修改</a>
									    <a href="${pageContext.request.contextPath}/sz/delete${resultSet.type}.action?id=${top.id}" class="delete">删除</a><span class="deleting" style="position:absolute;left:450px;display:none;background-color:#666;color:#fff;padding:10px;">删除中...</span></td>
							        </tr>
						       </c:forEach>
				   </tbody>
                </table>
             </div>
         </div>
         
          <div class="pages">
           <div id="search_con">
               <input type="hidden" name="actionName" value="${pageContext.request.contextPath}/sz/${resultSet.actionName}.action">
               <input type="hidden" name="type" value="${resultSet.type}">
               <input type="hidden" name="keyWord" value="${resultSet.keyWords}">
               <input type="hidden" name="idList" value="${resultSet.idList}">
               <input type="hidden" name="currentPage" value="${resultSet.pageInfo.currentPage}">
               <input type="hidden" name="totalPage" value="${resultSet.pageInfo.totalPage}">
            <p id="pages_num" class="pages_num">
             <a class="point" href=""><img alt="previousPages" src="../resource/images/prepoint_l.gif" /></a>
             <span>
             </span>
             <a class="point" href=""><img alt="forwardPages" src="../resource/images/prepoint_r.gif" /></a>
            </p>
            <p class="pages_sum">Pages:<span>1</span>&#47;<span>${resultSet.pageInfo.totalPage}</span></p>
            </div>
         </div>

         <div class="footer">
           <span>&copy;</span><span>电子科技大学数字媒体技术研究所</span><span>All rights reserved</span>
           <span>&#124;</span><span>Powered by Dreamfly</span>
         </div>
    </div>
   <script>
   $(document).ready(function(){
   var now_type=$("input[name=type]").val();
   		var list_table=$("#list_table");
   		list_table.find("td a.delete").click(function(){
   			var url=this.href;
   			var $this=$(this);
   			var $span=$(this).next();
   			$this.css('display','none');
   			$span.show();
   			$.ajax({
   				type:"GET",
   				url:url,
   				dataType:"text",
   				success:function(data){
   					if(data=="success"){
   						$this.parent().parent().remove();
   					}else{
                        $(document).replaceWith(data);
                        alert($(document).context);
   					}
   				}
   			});
   			return false;
   		});
   		list_table.find("th input").click(function(){
   			if(this.checked==true){
   				list_table.find("td input[type=checkbox]").attr("checked",true);
   			}else{
   				list_table.find("td input[type=checkbox]").attr("checked",false);
   			}
   		});
   		list_table.find("th a.delete").click(function(){
   			var url=this.href;
   			list_table.find("td input[type=checkbox]").each(function(){
   				if(this.checked==true){
                    url+="deleteIds="+this.value+"&";
   					var $this=$(this).parent().parent().find('a.delete');
   					$this.css('display','none');
   					$this.next().show();

   				}
   			});
   			$.ajax({
   				type:"GET",
   				url:url,
   				dataType:"text",
   				success:function(data){
   					if(data=="success"){
   						list_table.find("td input[type=checkbox]").each(function(){
   							if(this.checked==true){
   								$(this).parent().parent().remove();
   							}
   						});
   					}else{
   						alert("出错 请稍后再试");
   					}
   				}
   			});
   			return false;
   		});
   	$("ul#nav").find("a").click(function(){
       			$("ul#nav li.nav_current").removeClass("nav_current");
       			$(this).parent().addClass("nav_current");
       			var action_adr=$("#domain").val();
       			action_adr+="bg"+this.title+".action";
       			$("#key_form").attr("action",action_adr);
       			$("#key_search1 input[type=text]").attr("name",this.title.toLowerCase()+".title");
//       			return false;
       			
      });
      var li_nav_con=$("ul#nav");
   		li_nav_con.find("a").each(function(){
   			if(this.title==now_type){
   			    li_nav_con.find(".nav_current").removeClass("nav_current");
   				$(this).parent().addClass("nav_current");
   				var action_adr=$("#domain").val();
       			action_adr+="bg"+this.title+".action";
       			$("#key_form").attr("action",action_adr);
       			$("#key_search1 input[type=text]").attr("name",this.title.toLowerCase()+".title");
       			
   			}
   		}); 
     $("ul#pictureType li").each(function(){
          $(this).click(function(){
          	if($(this).attr("className")!="selected"){
          		$(this).attr({className: 'selected'});
                $("#key_form").append("<input type='hidden' name='szTypeIds' value='"+this.title+"' />");
          	}
             
          });
       });
      $("ul#pictureType li a.side_del").click(function(e){
       		var nameValue=this.title;
       		$("input[name=szTypeIds]").each(function(){
       			if(nameValue==this.value){
       				$(this).remove();
       			}
       		});
            e.stopPropagation();
           $(this).parent().removeClass();
       });
   		var $search_con=$("#search_con");
   		var url=$search_con.find("input[name=actionName]").val();
   		var keyWord=$search_con.find("input[name=keyWord]").val();
   		var ids=$search_con.find("input[name=idList]").val();
   		var current_i=$("input[name=currentPage]").val();
   		switch(now_type){
   			case 'Picture':
   				break
   			case 'Video':
   				changUpload('Video','视频上传');
   				break
   			case 'Audio':
   				changUpload('Audio','音频上传');
   				break
   			case 'Model':
   				changUpload('Model','模型上传');
   				break
   			case 'Activity':
   				changUpload('Activity','动作库上传');
   				break
   		}
   		function changUpload(type,type_ch){
   			var pic_type=$("#pic_type");
   			pic_type.css('display','none');
   			var pic_upload=$("#pic_upload");
   			pic_upload.text(type_ch);
   			pic_upload.attr('href','/shuzi/sz/initialUpload'+type+'.action');
   		}
   	});
   	$(document).ready(function(){// for divid page
   		var $search_con=$("#search_con");
   		var now_type=$("input[name=type]").val();
   		var url=$search_con.find("input[name=actionName]").val()+"?isAdmin=1";
   		var keyWord=$search_con.find("input[name=keyWord]").val();
   		var ids=$search_con.find("input[name=idList]").val();
   		var current_i=$("input[name=currentPage]").val();
   		var totalPage=$("input[name=totalPage]").val();
   		var pageFlag,queryname;
   		if(url.indexOf('content') != -1){
   			pageFlag="clientPage";
   			queryname="fileName"
   		}else{
   			pageFlag="page";
   			queryname=now_type.toLowerCase()+".title"
   		}
   		if(ids){
   		 ids=ids.replace(/,/g,"&szTypeIds=");
   		}
   		var numIndex=[];
   		if(parseInt(totalPage)<=5){
   			var indexFlag=parseInt(totalPage);
   			for(var i=0;i<indexFlag;i++){
   				numIndex.unshift(indexFlag-i);
   			}
   		}else if(parseInt(current_i)<=3){
   			numIndex=numIndex.concat(1,2,3,4,5);
   		}else if(parseInt(current_i)+2>=totalPage){
   			var indexFlag=parseInt(totalPage);
   			numIndex=numIndex.concat(indexFlag-4,indexFlag-3,indexFlag-2,indexFlag-1,indexFlag);
   		}else{
   			var indexFlag=parseInt(current_i);
   			numIndex=numIndex.concat(indexFlag-2,indexFlag-1,indexFlag,indexFlag+1,indexFlag+2);
   		}
   		var docFra=document.createDocumentFragment();
   		for(var i=0;i<numIndex.length;i++){
   			var in_a=document.createElement("a");
   			in_a.href=url+"&"+pageFlag+"="+numIndex[i]+"&"+queryname+"="+keyWord;
   			in_a.innerHTML=numIndex[i];
   			if(ids){
   				 in_a.href+="&szTypeIds="+ids;
   			}
   			if(numIndex[i]==current_i){
   					$(in_a).addClass("current");
   				}
   			docFra.appendChild(in_a); 
   		}
   		document.getElementById("pages_num").getElementsByTagName("span")[0].appendChild(docFra);
   		$("#pages_num a.point").each(function(i){
   		if(i==0){
   				this.href=url+"&"+pageFlag+"="+numIndex[0]+"&"+queryname+"="+keyWord;
   				if(ids){
   				  this.href+="&szTypeIds="+ids;
   				}
   			}else{
   				this.href=url+"&"+pageFlag+"="+numIndex[numIndex.length-1]+"&"+queryname+"="+keyWord;
   				if(ids){
   				  this.href+="&szTypeIds="+ids;
   				}
   			}
   		});
   	});
   </script>

</body>
</html>
